// 订单模块对应接口请求
import { request } from '@/api/index.js'

// 订单结算的接口请求
export const useCheckoutOrderService = async (mode, data) => {
  return request.get('/checkout/order', {
    params: {
      mode, //buyNow立即购买 cart购物车）
      delivery: 10, // 配送方式 （10快递配送 20上门自提） 默认10
      shopId: 0, // 自提门店id 默认 0
      couponId: 0, // 优惠券id 默认 0 无优惠
      isUsePoints: 0, //是否使用积分抵扣（1使用 0不使用）
      ...data
    }
  })
}

// 订单支付对应接口请求
export const useCommitOrderService = async (data) => {
  return request.post('/checkout/submit', {
    delivery: '10',
    couponld: 0,
    isUsePoints: 0,
    payType: 10,
    ...data
  })
}

// 获取用户所有订单信息
export const useGetUserOrderService = async (params) => {
  return request.get('/order/list', { params })
}

// 获取用户订单详情
export const useGetUserOrderDetailService = async (params) => {
  return request.get('/order/detail', { params })
}

// 取消订单
export const useCancelOrderService = async (data) => {
  return request.post('/order/cancel', data)
}

// 支付订单
export const usePayOrderService = async (params) => {
  return request.get('/order/pay', { params })
}

// 确认收货
export const useConfirmOrderService = async (data) => {
  return request.post('/order/receipt', data)
}
